golabels: ignore attach when Go plugins are loaded#1314
Merged
christos68k merged 3 commits intoApr 3, 2026
Merged
Conversation
ef89187 to
760c733
Compare
When a Go process loads shared libraries via plugin.Open(), the profiler creates separate golabels interpreter instances for each Go ELF file in the process. Since they all share the same PID-keyed eBPF map entry, the second Detach fails with "key does not exist". Fix by wrapping the error in DeleteProcData with %w so callers can inspect it, and ignoring ErrKeyNotExist in golabels Detach. Fixes open-telemetry#1301
florianl
reviewed
Apr 2, 2026
rogercoll
approved these changes
Apr 2, 2026
Contributor
rogercoll
left a comment
There was a problem hiding this comment.
Thanks! Maybe add a debug log line if something actually goes wrong with golabels in a multi-plugin process?
rogercoll
reviewed
Apr 2, 2026
florianl
reviewed
Apr 2, 2026
Comment on lines
+49
to
+52
| if err := ebpf.DeleteProcData(libpf.GoLabels, pid); err != nil && !errors.Is(err, cebpf.ErrKeyNotExist) { | ||
| return err | ||
| } | ||
| return nil |
Member
There was a problem hiding this comment.
This would also incorporate #1314 (comment):
Suggested change
| if err := ebpf.DeleteProcData(libpf.GoLabels, pid); err != nil && !errors.Is(err, cebpf.ErrKeyNotExist) { | |
| return err | |
| } | |
| return nil | |
| err := ebpf.DeleteProcData(libpf.GoLabels, pid) | |
| switch { | |
| case err == nil: return | |
| case errors.Is(err, cebpf.ErrKeyNotExist): | |
| log.Debugf("Entry for PID %d already removed", pid) | |
| return nil | |
| default: | |
| return err | |
| } |
Contributor
Author
There was a problem hiding this comment.
Don't need the err == nil case I think, I pushed a commit to add logging.
christos68k
approved these changes
Apr 2, 2026
|
|
||
| func (d *data) Detach(ebpf interpreter.EbpfHandler, pid libpf.PID) error { | ||
| return ebpf.DeleteProcData(libpf.GoLabels, pid) | ||
| // Go plugins share the runtime with the main binary, so multiple Go ELF |
Member
There was a problem hiding this comment.
It it worth further clarifying that Go does not support unloading plugins here? If one doesn't know that then one could think that we still have an issue.
Go plugins can't change go labels version/offset information nor the TLS information so ignore them by detecting when a go exe is a shared object.
Contributor
Author
|
I completely flipped this on its head and think its better to just ignore Go plugins, please take another look, thanks! |
gnurizen
added a commit
to parca-dev/opentelemetry-ebpf-profiler
that referenced
this pull request
May 4, 2026
gnurizen
added a commit
to parca-dev/opentelemetry-ebpf-profiler
that referenced
this pull request
May 5, 2026
gnurizen
added a commit
to parca-dev/opentelemetry-ebpf-profiler
that referenced
this pull request
May 12, 2026
This was referenced May 15, 2026
gnurizen
added a commit
to parca-dev/opentelemetry-ebpf-profiler
that referenced
this pull request
May 19, 2026
gnurizen
added a commit
to parca-dev/opentelemetry-ebpf-profiler
that referenced
this pull request
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a Go process loads shared libraries via
plugin.Open(), the profiler creates separategolabelsinterpreter instances for each Go ELF file in the process. Since Go plugins must be built with the same Go version as the host binary and share the runtime, they produce identicalGoLabelsOffsets— but both instances write and delete the same PID-keyed eBPF map entry.The second
Detachcall fails with "key does not exist" because the first instance already removed it.This fixes the issue by ignoring the attach of Go plugins, since the proc data would be the same there's no point in maintaining a golabels instance for it.
Fixes #1301